package com.fingard.dsp.web;

public class HttpResponse {
	
	public boolean isRtnBytes;
	
	public StringBuilder respHead;
	public String respCharset;
	public HttpResponse(){
		isRtnBytes = false;
		respHead = new StringBuilder();
	}
	
	public static String getContentType(String p_type, String p_browser){
		String fType = "";
		if(p_type != null){
			fType = p_type.toLowerCase();
		}
		if("jpg".equals(fType) || "jpeg".equals(fType)){
			return "image/jpeg";
		}else if("bmp".equals(fType) || "png".equals(fType) || "gif".equals(fType)){
			return "image/"+fType;
		}else if("mht".equals(fType)){
			if(HttpRequest.Browser_Chrome.equals(p_browser)){
				return "message/rfc822";//return "application/x-Internet Explorer";
			}else{
				return "message/rfc822";
			}
		}else if("htm".equals(fType) || "html".equals(fType)){
			return "text/html";
		}else if("txt".equals(fType) || "text".equals(fType)){
			return "text/plain";
		}else if("xml".equals(fType)){
			return "text/xml";
		}else if("json".equals(fType)){
			return "application/json";
		}else if("down".equals(fType)){
			return "application/force-download";
		}
		return "application/"+fType;
	}
	
	public String contentType;
	public void setContentType(String p_type, String p_browser){
		contentType = HttpResponse.getContentType(p_type, p_browser);
	}
	
	public String contentDisposition;
	
	public byte[] respBytes;
	
	public String respMsg;
}
